import request from '@/utils/request'

export const userMobileLogin = ({ mobile, password }) => {
  return request('/api/login', 'post', { mobile, password })
}

export const userMobileReg = ({ username, mobile, password }) => {
  return request('/api/reguser', 'post', { username, mobile, password })
}

// 用户中心获取用户基本信息
export const getUserInfo = () => {
  return request('/my/userinfo', 'get')
}

export const editUserInfo = ({ username, email }) => {
  return request('/my/userinfo', 'post', { username, email })
}

export const changePassword = ({ oldPassword, newPassword }) => {
  return request('/my/password', 'post', { oldPassword, newPassword })
}

// 调用头像库获取数据
export const getAvatardatabase = () => {
  return request('/my/avatardatabase', 'get')
}

// 刷新用户总得分
export const refreshSum = () => {
  return request('/my/refreshsum', 'get')
}

// 在评论界面调用id获取用户基本信息的接口
export const getUsercard = ({ id }) => {
  return request('/my/getusercard', 'post', { id })
}

// 关注用户接口
export const addFollow = (query, data) => {
  return request('/my/addFollow', 'post', query, data)
}

// 取消关注用户接口
export const deleteFollow = (query, data) => {
  return request('/my/deleteFollow', 'post', query, data)
}

// 根据列表数组获取用户基本信息
export const getuserlist = ({ list }) => {
  return request('/my/getUserlist', 'post', { list })
}

// 修改用户头像
export const updateAvatar = ({ avatar }) => {
  return request('/my/avatar', 'post', { avatar })
}
